java清除SharedReference中的单个变量
我的应用程序中保存了以下SharedPreference
:
editor.putString("strInfName", nameOfInf.getText().toString());
editor.putFloat("dblTollAmount", Float.parseFloat(tollAmount.getText().toString()));
如何只清除一个变量而不是两个
editor.clear();
将清除所有变量,但我只想清除,strInfName
而已
这是否有效:
editor.edit().remove("strInfName").commit();
# 1 楼答案
从docs开始: